<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="View.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>ToWa Webshop Checkout</title>
</head>
<body>

	<%
	ArrayList<OrderItemView> cart = (ArrayList<OrderItemView>) request.getSession().getAttribute("cart");
	%>

<div id="container">
	<jsp:include page="header.jsp" />
	<jsp:include page="menu.jsp" />
	<div id="content">
		<%
		if (cart != null) {
		%>
		<form action="item" method="post">
			<table>
				<tr>
					<td>Shopping cart</td>
				</tr>
				<tr>
					<th>Item</th>
					<th>Price</th>
					<th>Amount</th>
				</tr>
				<%
				for (int i = 0; i < cart.size(); i++) {
				%>
					<tr>
						<td><%=cart.get(i).getItem().getName()%></td><td><%=cart.get(i).getItem().getPrice()%></td>
						<td><input type="text" size="1" value="<%=cart.get(i).getAmount()%>" name="amount_<%=cart.get(i).getItem().getItemId()%>" /></td>
					</tr>
				<%	
				}
			}
			%>
			<tr>
				<td></td><td>Total price: <%=Controller.getTotalPriceOfCart(cart)%></td><td><input type="submit" value="update" /></td>
			</table>
			<input type="hidden" name="hidden" value="updateCheckout" />
		</form>
		<form action="item" method="post">
			<input type="submit" value="Order items!" />
			<input type="hidden" name="hidden" value="doneAndOrder" />
		</form>
	</div>
	<jsp:include page="shoppingcart.jsp" />
	<jsp:include page="footer.jsp" />
</div>

</body>
</html>